package com.itheima.stream;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;


public class Demo4 {
    public static void main(String[] args) {
        ArrayList<Integer> list=new ArrayList<>();
        for (int i = 0; i <=10 ; i++) {
            list.add(i);
        }
        Collections.addAll(list,10,10);
        //Stream流上将操作过的数据重新封装一遍下次使用_________>collect()方法用于收集数据
        // _____>通过Collectors类的静态方法toList/toSet/toMap装进对应的集合
        List<Integer> list1 = list.stream().filter(number -> number % 2 == 0).collect(Collectors.toList());
        System.out.println(list1);
        Set<Integer> list2 = list.stream().filter(number -> number % 2 == 0).collect(Collectors.toSet());
        System.out.println(list2);
    }
}
